<?php session_start();
if (!isset($_SESSION["username"])) {
    header("Location:workerlogin.html");
} else {
    $username = $_SESSION['username'];
    @$category = $_REQUEST['category'];
    @$basis = $_REQUEST['basis'];
    $a = mysqli_connect("localhost", "root", "deng123", "housekeeping", "3306") or die("unable to connect");
    @$q = "SELECT * FROM worker_details where username='$username'";
    @$res = mysqli_query($a, $q);
    if ($res) {
        if ($basis == 'Individual') {
?>
            <!DOCTYPE html>
            <html lang="en">

            <head>
                <!-- Required meta tags-->
                <meta charset="utf-8">
                <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
                <meta name="description" content="">
                <meta name="author" content="">
                <meta name="viewport" content="width=device-width, initial-scale=1">
                <title>好先生 | 家政服务</title>
                <link rel="shortcut icon" href="img/favicon.ico" />
                <!-- Icons font CSS-->
                <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
                <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet">
                <link rel="stylesheet" href="vendor/simple-line-icons/css/simple-line-icons.css">
                <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
                <link href="https://fonts.googleapis.com/css?family=Catamaran:100,200,300,400,500,600,700,800,900" rel="stylesheet">
                <link href="https://fonts.googleapis.com/css?family=Muli" rel="stylesheet">
                <link href="vendor/mdi-font/css/material-design-iconic-font.min.css" rel="stylesheet" media="all">
                <link href="vendor/font-awesome-4.7/css/font-awesome.min.css" rel="stylesheet" media="all">
                <!-- Font special for pages-->
                <link href="https://fonts.googleapis.com/css?family=Poppins:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">

                <!-- Vendor CSS-->
                <link href="vendor/select2/select2.min.css" rel="stylesheet" media="all">
                <link href="css/hover-min.css" rel="stylesheet">


                <!-- Main CSS-->
                <link href="css/main.css" rel="stylesheet" media="all">
                <link href="css/style.css" rel="stylesheet" media="all">
                <script>
                    function myFunction() {
                        var age = document.getElementById("age").value;
                        if (age < 18) {
                            alert("Worker below 18 years old is not allowed");
                            return false;
                        }
                    }
                </script>
            </head>

            <body>
                <nav class="navbar navbar-expand-lg navbar-light fixed-top" style="background:-webkit-gradient(linear, right top, left top, from(#1da1f2), to(#005f7f));" id="mainNav">
                    <div class="container">
                        <div class="navbar-header">
                            <a class=" nav-link js-scroll-trigger" href="#top">
                                <img class="img-rounded" src="img/logo.png" />
                            </a>
                        </div>
                        &nbsp;
                        <a class="navbar-brand " href="#page-top">
                            <h2><small style="font-family: Arial;border-bottom: 2px solid gainsboro"><?php echo $_SESSION['name']; ?></small></h2>
                        </a>
                        <button class="navbar-toggler navbar-toggler-right ml-auto" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
                            菜单
                            <i class="fas fa-bars"></i>
                        </button>
                        <div class="collapse navbar-collapse" id="navbarResponsive">
                            <ul class="navbar-nav ml-auto">
                                <li class="nav-item">
                                    <a class="nav-link js-scroll-trigger hvr-glow" href="worker_profile.php">员工档案</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link js-scroll-trigger hvr-glow " href="worker_service.php">服务记录</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link js-scroll-trigger hvr-glow " href="worker_help.php">帮助</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link js-scroll-trigger hvr-glow " href="w_logout.php">退出</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </nav>
                <section class="features tb bb" id="features">
                    <form action="worker_personal.php" method="post">
                        <input type="submit" class="cont_button2 btn-dark" value="<< 返回">
                    </form>

                    <?php
                    while ($row = mysqli_fetch_array($res)) {
                        $dbname = $row['name'];
                        $dbemail = $row['email'];
                        $dbgender = $row['gender'];
                        $dbcity = $row['city'];
                        $dbarea = $row['subarea'];
                        $dbphone = $row['phone'];
                        $dbpassword = $row['password'];
                        $dbquestion = $row['question'];
                        $dbanswer = $row['answer'];
                        $dbage = $row['age'];
                    }
                    ?><br>
                    <center>
                        <h3 style="font-size: 40px" class="text-light"><u>编辑个人资料</u></h3>
                    </center><br>
                    <div class="container">
                        <div class="row">
                            <form action="worker_p_edit_next.php" method="post" onsubmit="return myFunction()">
                                <div class="row">
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <b style="font-size: 20px" class="text-warning">补充名字:</b>
                                            <input type="text" name="name" class="form-control" value="<?php echo $dbname ?>" required />
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <b style="font-size: 20px" class="text-warning">邮箱:</b>
                                            <input type="email" name="email" class="form-control" value="<?php echo $dbemail ?>" required />
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <b style="font-size: 20px" class="text-warning">手机号 :</b>
                                            <input type="text" minlength="11" maxlength="11" name="phone" class="form-control" value="<?php echo $dbphone ?>" required />
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <b style="font-size: 20px" class="text-warning">城市 :</b>
                                            <select name="city" class="form-control">
                                                <option value="<?php echo $dbcity ?>" selected><?php echo $dbcity ?></option>
                                                <option value="广东">广东</option>
                                                <option value="北京市">北京市</option>
                                                <option value="上海市">上海市</option>
                                                <option value="四川省">四川省</option>
                                                <option value="深圳">深圳</option>
                                                <option value="香港">香港</option>
                                                <option value="天津">天津</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <b style="font-size: 20px" class="text-warning">安全问题 :</b>
                                            <select name="question" class="form-control">
                                                <option value="<?php echo $dbquestion ?>" selected><?php echo $dbquestion ?></option>
                                                <option value="奶奶名字">你的奶奶叫什么名字？</option>
                                                <option value="旧手机号">你的旧电话号码是多少？</option>
                                                <option value="我的小名">你的小名叫什么?</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <b style="font-size: 20px" class="text-warning">问题答案 :</b>
                                            <input type="text" name="answer" class="form-control" value="<?php echo $dbanswer ?>" required />
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <b style="font-size: 20px" class="text-warning">性别 :</b>
                                            <select name="gender" class="form-control">
                                                <option value="<?php echo $dbgender ?>" selected><?php echo $dbgender ?></option>
                                                <option value="male">male</option>
                                                <option value="female">female</option>
                                                <option value="other">other</option>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <b style="font-size: 20px" class="text-warning">年龄 :</b>
                                            <input type="text" minlength="2" maxlength="2" id="age" name="age" class="form-control" value="<?php echo $dbage ?>" required />
                                        </div>
                                    </div>
                                    <div class="col-md-2"></div>
                                    <div class="col-md-6">
                                        <input type="hidden" name="category" value="<?php echo $category; ?>">
                                        <input type="hidden" name="basis" value="<?php echo $basis; ?>">
                                        <input style="font-size: 14px;padding-bottom: 5px;padding-top: 5px" class="btnRegister" type="submit" value="下一步 >>">
                                    </div>
                                </div>
                            </form>
                            <br>
                        </div><br>
                        <center>
                            <h3 class="text-light">如果需要更新您的身份证明文件和身份证号码，请邮寄至管理员:</h3><br>
                            <h4 class="text-light">邮箱: 1509939219@qq.com</h4>
                        </center>
                    </div>
                    <br>
                </section>
                <!-- Jquery JS-->
                <script src="vendor/jquery1/jquery.min.js"></script>
                <!-- Vendor JS-->
                <script src="vendor/select2/select2.min.js"></script>
                <script src="vendor/jquery-validate/jquery.validate.min.js"></script>
                <script src="vendor/bootstrap-wizard/bootstrap.min.js"></script>
                <script src="vendor/bootstrap-wizard/jquery.bootstrap.wizard.min.js"></script>
                <script src="vendor/datepicker/moment.min.js"></script>
                <script src="vendor/datepicker/daterangepicker.js"></script>
                <script src="vendor/jquery/jquery.min.js"></script>
                <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

                <!-- Plugin JavaScript -->
                <script src="vendor/jquery-easing/jquery.easing.min.js"></script>


                <script src="js/new-age.min.js"></script>

                <!-- Main JS-->
                <script src="js/global.js"></script>
                <footer>
                    <div class="container">
                        <p>&copy; 好先生 家政服务. 版权所有.</p>
                        <ul class="list-inline">
                            <li class="list-inline-item">
                                <a href="#">隐私</a>
                            </li>
                            <li class="list-inline-item">
                                <a href="#">条款</a>
                            </li>
                        </ul>
                    </div>
                </footer>
            </body>
            <!-- end document-->

            </html>
        <?php
        } else {
        ?>
            <!DOCTYPE html>
            <html lang="en">

            <head>
                <!-- Required meta tags-->
                <meta charset="utf-8">
                <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
                <meta name="description" content="">
                <meta name="author" content="">
                <meta name="viewport" content="width=device-width, initial-scale=1">
                <title>好先生 | 家政服务</title>
                <link rel="shortcut icon" href="img/favicon.ico" />
                <!-- Icons font CSS-->
                <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
                <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet">
                <link rel="stylesheet" href="vendor/simple-line-icons/css/simple-line-icons.css">
                <link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
                <link href="https://fonts.googleapis.com/css?family=Catamaran:100,200,300,400,500,600,700,800,900" rel="stylesheet">
                <link href="https://fonts.googleapis.com/css?family=Muli" rel="stylesheet">
                <link href="vendor/mdi-font/css/material-design-iconic-font.min.css" rel="stylesheet" media="all">
                <link href="vendor/font-awesome-4.7/css/font-awesome.min.css" rel="stylesheet" media="all">
                <!-- Font special for pages-->
                <link href="https://fonts.googleapis.com/css?family=Poppins:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">

                <!-- Vendor CSS-->
                <link href="vendor/select2/select2.min.css" rel="stylesheet" media="all">
                <link href="css/hover-min.css" rel="stylesheet">


                <!-- Main CSS-->
                <link href="css/main.css" rel="stylesheet" media="all">
                <link href="css/style.css" rel="stylesheet" media="all">
            </head>

            <body>
                <nav class="navbar navbar-expand-lg navbar-light fixed-top" style="background:-webkit-gradient(linear, right top, left top, from(#1da1f2), to(#005f7f));" id="mainNav">
                    <div class="container">
                        <div class="navbar-header">
                            <a class=" nav-link js-scroll-trigger" href="#top">
                                <img class="img-rounded" src="img/logo.png" />
                            </a>
                        </div>
                        &nbsp;
                        <a class="navbar-brand " href="#page-top">
                            <h2><small style="font-family: Arial;border-bottom: 2px solid gainsboro"><?php echo $_SESSION['name']; ?></small></h2>
                        </a>
                        <button class="navbar-toggler navbar-toggler-right ml-auto" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
                            菜单
                            <i class="fas fa-bars"></i>
                        </button>
                        <div class="collapse navbar-collapse" id="navbarResponsive">
                            <ul class="navbar-nav ml-auto">
                                <li class="nav-item">
                                    <a class="nav-link js-scroll-trigger hvr-glow" href="worker_profile.php">员工档案</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link js-scroll-trigger hvr-glow " href="worker_service.php">服务记录</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link js-scroll-trigger hvr-glow " href="worker_help.php">帮助</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link js-scroll-trigger hvr-glow " href="w_logout.php">退出</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </nav>
                <section class="features tb bb" id="features">
                    <form action="worker_personal.php" method="post">
                        <input type="submit" class="cont_button2 btn-dark" value="<< 返回">
                    </form>

                    <?php
                    while ($row = mysqli_fetch_array($res)) {
                        $dbname = $row['name'];
                        $dbemail = $row['email'];
                        $dbcity = $row['city'];
                        $dbarea = $row['subarea'];
                        $dbphone = $row['phone'];
                        $dbquestion = $row['question'];
                        $dbanswer = $row['answer'];
                    }
                    ?><br>
                    <center>
                        <h3 style="font-size: 40px" class="text-light"><u>编辑公司信息</u></h3>
                    </center><br>
                    <div class="container">
                        <div class="row">
                            <form action="worker_p_edit_next.php" method="post">
                                <div class="row">
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <b style="font-size: 20px" class="text-warning">公司名称:</b>
                                            <input type="text" name="name" class="form-control" value="<?php echo $dbname ?>" required />
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <b style="font-size: 20px" class="text-warning">邮箱:</b>
                                            <input type="email" name="email" class="form-control" value="<?php echo $dbemail ?>" required />
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <b style="font-size: 20px" class="text-warning">手机号 :</b>
                                            <input type="text" minlength="11" maxlength="11" name="phone" class="form-control" value="<?php echo $dbphone ?>" required />
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <b style="font-size: 20px" class="text-warning">城市 :</b>
                                            <select name="city" class="form-control">
                                                <option value="<?php echo $dbcity ?>" selected><?php echo $dbcity ?></option>
                                                <option value="广东">广东</option>
                                                <option value="北京市">北京市</option>
                                                <option value="上海市">上海市</option>
                                                <option value="四川省">四川省</option>
                                                <option value="深圳">深圳</option>
                                                <option value="香港">香港</option>
                                                <option value="天津">天津</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <b style="font-size: 20px" class="text-warning">安全问题 :</b>
                                            <select name="question" class="form-control">
                                                <option value="<?php echo $dbquestion ?>" selected><?php echo $dbquestion ?></option>
                                                <option value="公司私人邮箱">你的公司私人邮箱?</option>
                                                <option value="公司的核心思想">你公司的核心思想是什么？</option>
                                                <option value="Favourite Meal of 公司名称">你公司的公司名称最喜欢吃什么?</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <b style="font-size: 20px" class="text-warning">问题答案 :</b>
                                            <input type="text" name="answer" class="form-control" value="<?php echo $dbanswer ?>" required />
                                        </div>
                                    </div>
                                    <div class="col-md-2"></div>
                                    <div class="col-md-6">
                                        <input type="hidden" name="category" value="<?php echo $category; ?>">
                                        <input type="hidden" name="basis" value="<?php echo $basis; ?>">
                                        <input style="font-size: 14px;padding-bottom: 5px;padding-top: 5px" class="btnRegister" type="submit" value="下一步 >>">
                                    </div>
                                </div>
                            </form>
                        </div>
                        <br><br><br>
                        <center>
                            <h3 class="text-light">如果需要更新您的身份证明文件和身份证号码，请邮寄至管理员:</h3><br>
                            <h4 class="text-light">邮箱: 1509939219@qq.com</h4>
                        </center>
                    </div>
                    <br>
                </section>
                <!-- Jquery JS-->
                <script src="vendor/jquery1/jquery.min.js"></script>
                <!-- Vendor JS-->
                <script src="vendor/select2/select2.min.js"></script>
                <script src="vendor/jquery-validate/jquery.validate.min.js"></script>
                <script src="vendor/bootstrap-wizard/bootstrap.min.js"></script>
                <script src="vendor/bootstrap-wizard/jquery.bootstrap.wizard.min.js"></script>
                <script src="vendor/datepicker/moment.min.js"></script>
                <script src="vendor/datepicker/daterangepicker.js"></script>
                <script src="vendor/jquery/jquery.min.js"></script>
                <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

                <!-- Plugin JavaScript -->
                <script src="vendor/jquery-easing/jquery.easing.min.js"></script>


                <script src="js/new-age.min.js"></script>

                <!-- Main JS-->
                <script src="js/global.js"></script>
                <footer>
                    <div class="container">
                        <p>&copy; 好先生 家政服务. 版权所有.</p>
                        <ul class="list-inline">
                            <li class="list-inline-item">
                                <a href="#">隐私</a>
                            </li>
                            <li class="list-inline-item">
                                <a href="#">条款</a>
                            </li>
                        </ul>
                    </div>
                </footer>
            </body>
            <!-- end document-->

            </html>
<?php
        }
    }
}
?>